// use localStorage to store the authority info, which might be sent from server in actual project.
const moment = require('moment');

export function getAuthority() {
  const ts = localStorage.getItem('loginTs');
  const time = Date.now() - ts;
  let auth = time < 1800000 ? localStorage.getItem('antd-pro-authority') || 'guest' : 'guest';
  return auth;

}

export function setAuthority(authority) {
  //const ts = moment().format('YYYY-MM-DD HH:mm:ss');
  localStorage.setItem('loginTs', Date.now());
  return localStorage.setItem('antd-pro-authority', authority);
}

export function setUser(userStr) {
  return localStorage.setItem('user', userStr);
}
